home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Belgian Amiga Club - ADF Collection
/
BS1 part 05.zip
/
BS1 part 5
/
IM_3 .adf
/
Exec
/
piarc.LZH
/
NJPLR.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1992-07-11
|
7KB
|
277 lines
/*
* njplr.rexx
*
* Written by: Pete Patterson
* Last Update: January 15, 1992
* For: Black Belt Systems image processing series IM, IM F/c, and IP.
* ---------------------------------------------------------------------------
* Revision: 1.0
*/
/*
* open rexxsupport.library -- needed for some functions
*/
if ~show('L',"rexxsupport.library") then do
if addlib('rexxsupport.library',0,-30,0) then do
/* everything's ok */
end;
else do
say 'We Have A Library Problem, Unable To Load "rexxsupport.library"';
say 'Cannot operate targar.rexx without this library - sorry!';
exit 10;
end;
end;
/*
* This will automatically direct the script to the proper
* software, if it is running.
*/
prtnme = 'IP_Port'; /* assume Image Professional */
if show('P','IP_Port') = 0 then do
if show('P','IM_Port') = 0 then do
say "Can't find image processor's ARexx port!!!"; /* not running? */
say "This script requires IP, IM or IM F/c to run!";
exit(20);
end;
else do
prtnme = 'IM_Port'; /* That's the thing about assumptions... */
end; /* We make em, user's break em. */
end;
options;
address;
prevpath = 'ram:'; /* put user in ram to start with... */
if show('C',njplpath) = 1 then do
prevpath = getclip(njplpath);
end;
address(prtnme);
options results;
'current';
bufdata = result; /* get name of buffer, if there is one */
parse var bufdata bname ',' bnum ',' bx ',' by ',' btot ',' bmem ',' bparname ',' bparnum;
if bname ~= '<none>' then do
bufname = bname;
end;
'filerequest "'||prevpath||'","'||bufname||'","","Load NJPL"';
njplfile = result;
options;
if njplfile = 'FR_CANCELLED' then do
address(prtnme);
'imtofront';
exit 0;
end;
njplfile = expandfilename(njplfile);
thispath = gimmepath(njplfile);
call setclip(njplpath,thispath);
address command 'cmpi:NJPLRD c "'||njplfile||'"';
if rc ~= 0 then do
address(prtnme);
'message "Cannot read '||njplfile||'"';
exit 0; /* this is not a proper NJPL file */
end;
call open(fhandle,'ram:IP_LDNJPL.tmp','read'); /* open the file */
rstring = readln(fhandle);
call close(fhandle); /* close the file */
address command 'c:delete >nil: ram:IP_LDNJPL.tmp';
parse var rstring width '/' height
if height < 0 then do
'message "Bad Height: '||height||'"';
exit 0;
end;
if height > 8192 then do
'message "Bad Height: '||height||'"';
exit 0;
end;
if width < 0 then do
'message "Bad Width: '||width||'"';
exit 0;
end;
if width > 8192 then do
'message "Bad Width: '||width||'"';
exit 0;
end;
address(prtnme);
options results;
'gadgets "Load","'||Width||' by '||Height||'","Half","Size","Quarter","Size","Eight","Size"';
pxsz = result-1;
options;
if pxsz < 0 then do
address;
exit 0;
end
if pxsz = 0 then do
scl = 1;
end
if pxsz = 1 then do
scl = 2;
width = width / 2;
height = height / 2;
end
if pxsz = 2 then do
scl = 4;
width = width / 4;
height = height / 4;
end
if pxsz = 3 then do
scl = 8;
width = width / 8;
height = height / 8;
end
'imtofront'; /* show user the IM screen */
/* is there already a primary buffer??? */
options results;
'current';
bufdata = result;
options;
mknewbuff = 1;
parse var bufdata bname ',' bnum ',' bx ',' by ',' btot ',' bmem ',' bparname ',' bparnum
if bname ~= '<none>' then
do
address(prtnme);
options results;
mknewbuff = 1;
'askyn '||'"Replace Primary ['||bname||']" "New As Primary"'
prefs = result;
options;
address;
if prefs = 0 then
do
address(prtnme);
'killbuff '||bnum; /* this kills the Primary Buffer */
address;
end;
end;
'autoredraw 0';
if mknewbuff = 1 then do
/* New buffer is created at current resolution */
address(prtnme);
'newbuf '||width||' '||height;
options results;
'current';
bufdata = result;
options;
parse var bufdata bname ',' bnum ',' bx ',' by ',' btot ',' bmem ',' bparname ',' bparnum
if bname = '<none>' then do
'message "Can`t get buffer."';
'autoredraw 1';
exit 0;
end;
'rename '||bnum||' 'gxname;
address;
end;
address(prtnme);
options results;
'askyn '||'"Save Image Info as File" "Don`t Save Image Info"'
prefs = result;
options;
svinfo = 0;
address;
if prefs = 0 then
do
options results;
'filerequest "'||prevpath||'","'||bufname||'","","Save TEXT"';
svinfo = 1;
njplfile2 = result;
options;
end;
address(prtnme);
options results;
'jackin';
jackadr = result;
options;
'wbtofront';
if (svinfo = 1) then
do
address command 'cmpi:NJPLRD d'||jackadr||' "'||njplfile||'" '||scl||' "'||njplfile2||'"';
end;
else
do
address command 'cmpi:NJPLRD d'||jackadr||' "'||njplfile||'" '||scl;
end;
address(prtnme);
'imtofront';
'redraw';
'autoredraw 1';
address;
exit 0;
/*
* gimmepath
*
* This takes the provided argument and sucks the path out of it, then
* returns that path to the caller, sans file name.
*/
gimmepath:
arg fullnamegx;
tempgx = reverse(fullnamegx);
lengx = length(fullnamegx); /* get length of string */
slashdex = index(tempgx,'/'); /* first occurance of '/' from right */
colondex = index(tempgx,':'); /* first occurance of ':' from right */
seploc = 0; /* assumes current dir, no path supplied */
if slashdex ~= 0 then do /* we assume we are in a DIR */
seploc = (lengx - slashdex)+1;
end;
else do
if colondex ~= 0 then do /* we assume we are on a device */
seploc = (lengx - colondex)+1;
end;
end;
gxname = substr(fullnamegx,seploc+1); /* if you ever need it */
gxpath = left(fullnamegx,seploc);
return(gxpath);
/*
* Since this script can't be expected to know where the CD of the user
* is when this cmd is invoked, we have to check the path the user
* provides - if it's not specified right from a root, then we have
* to make it a complete specification from the root.
*/
expandfilename:
parse arg jfile;
if index(jfile,':') = 0 then do
curdir = pragma(D);
if right(curdir,1) ~= ':' then do
if right(curdir,1) ~= '/' then do
if curdir ~= '' then do
curdir = curdir || '/';
end;
end;
end;
jfile = curdir||jfile;
end;
return(jfile);
rvalue:
wordnum = c2d(readch(fhandle,1)) * 256;
wordnum = wordnum + c2d(readch(fhandle,1));
return wordnum;